<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        .content {
            width: 400px;
            height: 400px;
            border: 1px solid #eeeeee;
            border-radius: 6px;
            box-shadow: 5px 5px 5px #cccccc;
        }
        .btn {
            width: 60px;
            height: 30px;
            border: 1px solid #eeeeee;
            border-radius: 6px;
            line-height: 30px;
            text-align: center;
            color: white;
            background-color:#56a5f1;
            outline: none;
        }
        .mask {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(1, 1, 1, 0.6);
        }
        .loading {
            position: absolute;
            top: 100px;
            margin-left: 50%;
            left: -50px;
            width: 0px;
            height: 0px;
            border-top: 50px solid red;
            border-left: 50px solid rgb(241, 199, 146);
            border-right: 50px solid rgb(128, 221, 128);
            border-bottom: 50px solid rgb(189, 145, 229);
            border-radius: 50%;
        }
        .triangle {
            display: inline-block;
            width: 0px;
            height: 0px;
            border-top: 20px solid red;
            border-left: 10px solid transparent;
            border-right: 10px solid transparent;
            border-bottom: 20px solid rgb(189, 145, 229);
            transform: rotate(30deg);
        }
    </style>
    <title>Document</title>
</head>
<body>
    <label for="">音乐id：</label>
    <input type="text" placeholder="请输入id" class="id" value="28012031">
    <br>
    <label for="">请选择查看类型：</label>
    <label for="song">歌曲</label>
    <input type="radio" name="type" id="song" value="song">
    <label for=" lyric">歌词</label>
    <input type="radio" name="type" id="lyric" value="lyric">
    <label for="comments">评论</label>
    <input type="radio" name="type" id="comments" value="comments">
    <label for="detail">详情</label>
    <input type="radio" name="type" id="detail" value="detail">
    <br>
    <button class="btn">搜索</button>
    <div class="triangle"></div>
    <p class="content"></p>
    <!--幕遮，在请求网络时的屏幕显示-->
    <div class="mask">
        <div class="loading">
        </div>
    </div>

    <script src="js/jquery-3.3.1.min.js"></script>
    <script>
        $(function() {
            $('.btn').click(function() {
                $('.mask').show();
                var id = $('.id').val();
                var url = `https://api.imjad.cn/cloudmusic/`;
                var type = $('input[type=radio]:checked').val();
                //https://api.imjad.cn/cloudmusic/?type=song&id=28012031&br=128000
                $.ajax({
                    url: url,
                    method: 'GET',
                    data: {
                        type: type,
                        id : id,
                        br: '128000'
                    },
                    success: function(result){
                        console.log(result);
                        let text = '';
                        if (type == 'song') {
                            text = `<a href=${result.data[0].url} target=_blank>点击试听</a>`
                        } else if (type == 'lyric') {
                            text = `<p>${result.lrc.lyric}</p>`
                        } else if (type == 'comments'){
                            text = '<p>无</p>'
                        } else if (type == 'detail'){
                            text = `<img width=350 height=350 src=${result.songs[0].al.picUrl} />`;
                        }
                        $('.content').html(text);
                        $('.mask').hide();
                    }

                })
            })
        })
    </script>
</body>
</html>